<?php
require_once 'libs/auth.class.php';
require_once 'libs/mysql.class.php';

$conn = new Mysql();
$auth = new Auth();

if ( isset($_POST['submit']) ) {
	$login    = $_POST['login'];
	$password = $_POST['password'];
	$auth->connect($login, $password);
}

if ( $auth->is_connected() ) {
	header('Location: index.php');
	exit();
}

require_once 'libs/Twig/Autoloader.php';
Twig_Autoloader::register();

$loader = new Twig_Loader_Filesystem('templates');
$twig = new Twig_Environment(
    $loader, 
	array(
	    /*'cache' => '/path/to/compilation_cache',*/
    )
);

$tplVars = array();

$tplVars['jsFiles'] = array(
    'bootstrap/js/jquery.min.js',
    'bootstrap/js/unicorn.login.js',
);


echo $twig->render('login.twig', $tplVars);